package com.seeyon.apps.kkSample.utils.kit;

import com.seeyon.ctp.common.log.CtpLogFactory;
import com.seeyon.ctp.organization.po.OrgMember;
import com.seeyon.ctp.util.DBAgent;
import org.apache.commons.logging.Log;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhangwy
 * @title: OrgMemberKit
 * @description: 人员工具类
 * @date 2023/11/22  17:33
 */
public class OrgMemberKit {
    private static Log logger = CtpLogFactory.getLog(OrgMemberKit.class);
    public static OrgMember getUserByCode(String userCode) {
        Long userId = -1L;
        try {
            String hql = "from OrgMember where code=:code and enable=true";
            Map<String, Object> pars = new HashMap();
            pars.put("code", userCode);
            List<OrgMember> result = DBAgent.find(hql, pars);
            if(result.size() > 0) {
                return result.get(0);
            }
        } catch (Exception e) {
            logger.error("-据用户编码获取用户ID出错！", e);
        }
        return null;
    }
}
